local shuihuo = fk.CreateSkill {
  name = "th_shuihuo",
  max_round_use_time = 1,
}

shuihuo:addEffect(fk.EventPhaseProceeding, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(shuihuo.name) and target and target.phase == Player.Start
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = shuihuo.name,
      prompt = "#th_shuihuo-ask:" .. target.id
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    target:drawCards(1, shuihuo.name)
    if target == player or target:getHandcardNum() > player:getHandcardNum() then
      player:drawCards(1, shuihuo.name)
    end
    room:setPlayerMark(target, "_th_shuihuo-turn", 1)
  end,
}, { check_skill_limit = true })
shuihuo:addEffect(fk.Damage, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("_th_shuihuo-turn") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:addPlayerMark(player, "@th_shuihuo-turn", data.damage)
  end,
})
shuihuo:addEffect("maxcards", {
  fixed_func = function (self, player)
    if player:getMark("_th_shuihuo-turn") > 0 then
      return player:getMark("@th_shuihuo-turn")
    end
  end,
})

Fk:loadTranslationTable{
  ["th_shuihuo"] = "水祸",
  [":th_shuihuo"] = "每轮限一次，一名角色的准备阶段，你可以令其摸一张牌，若为你或其手牌数大于你则你摸一张牌，然后其本回合手牌上限等于其本回合造成的伤害值。",

  ["#th_shuihuo-ask"] = "水祸：你可以令 %src 摸一张牌，其本回合手牌上限等于其本回合造成的伤害值",

  ["@th_shuihuo-turn"] = "水祸",
}

return shuihuo